package com.szp.lagou.oss.aliyun.controller;

import com.szp.lagou.oss.aliyun.bean.ResponseResult;
import com.szp.lagou.oss.aliyun.service.AliyunOssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/pic")
public class AliyunOssController {
    @Autowired
    AliyunOssService aliyunOssService;

    @RequestMapping("/upload")
    public ResponseResult upload(@RequestParam("file")MultipartFile multipartFile){
        return aliyunOssService.upload(multipartFile);
    }

    @RequestMapping("/download")
    public ResponseEntity download(String url){
        return aliyunOssService.download(url);
    }

    @RequestMapping("/delete")
    public ResponseResult delete(String url){
        return aliyunOssService.delete(url);
    }
}
